home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / picture / atring.c < prev    next >
Text File  |  1993-09-23  |  2KB  |  68 lines

  1. //    Copyright 1993 Ralph Gonzalez
  2.  
  3. /*
  4. *    FILE:        atring.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    November 9, 1990
  7. *
  8. *    defines methods for atomic ring animated segment
  9. */
  10.  
  11. # include    "atring.h"
  12. # include    "trans.h"
  13. # include    "cube.h"
  14.  
  15. # define    NUM_SATELLITES        2
  16. # define    RADIUS                2.
  17. # define    SATELLITE_TYPE        Fast_Cube
  18. # define    ANIMATED_SATELLITES    FALSE
  19. # define    ANGULAR_VELOCITY    -PI/10.
  20.  
  21. /******************************************************************
  22. *    initialize
  23. ******************************************************************/
  24. Atomic_Ring::Atomic_Ring(void)
  25. {
  26.     int                i;
  27.     Translation        *transl;
  28.     Scaling            *scale;
  29.     Rotation_Z        *roty;
  30.     Transformation    *combination1,
  31.                     *combination2;
  32.     
  33.     transl = new Translation;
  34.     transl->set(RADIUS-.5,-.5,-.5);
  35.     scale = new Scaling;
  36.     scale->set(.2,.2,.2);
  37.     roty = new Rotation_Z;
  38.     combination1 = new Transformation;
  39.     combination2 = new Transformation;
  40.     
  41.     num_segments = NUM_SATELLITES;
  42.     
  43.     for (i=0 ; i<NUM_SATELLITES ; i++)
  44.     {
  45.         segment[i] = new SATELLITE_TYPE;
  46.         roty->set(i*2.*PI/NUM_SATELLITES);
  47.         combination1->combine(transl,roty);
  48.         combination2->combine(combination1,scale);
  49.         segment[i]->move(combination2);
  50.         animation[i] = new Rotation_Z;
  51.         ((Rotation_Z*) animation[i])->set(ANGULAR_VELOCITY);
  52.         if (ANIMATED_SATELLITES)
  53.             log_animated_segment(segment[i]);
  54.     }
  55.     
  56.     segment[i=num_segments++] = new Fast_Cube;
  57.     transl->set(-.5,-.5,-.5);
  58.     segment[i]->move(transl);
  59.     animation[i] = new Transformation;
  60.     
  61.     delete transl;
  62.     delete scale;
  63.     delete roty;
  64.     delete combination1;
  65.     delete combination2;
  66. }
  67.  
  68.